package com.bosc.modeling.service;

import com.bosc.modeling.dao.gen.CompetitionEntityMapper;
import com.bosc.modeling.dao.gen.UserEntityMapper;
import com.bosc.modeling.pojo.gen.CompetitionEntityExample;
import com.bosc.modeling.pojo.gen.UserEntityExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StatisticsInfoService {
    @Autowired
    UserEntityMapper userEntityMapper;
    @Autowired
    CompetitionEntityMapper competitionEntityMapper;

    public long countUsers(){
        UserEntityExample example = new UserEntityExample();
        return userEntityMapper.countByExample(example);
    }
    public long countCompetitions(){
        CompetitionEntityExample example = new CompetitionEntityExample();
        return competitionEntityMapper.countByExample(example);
    }
    public long countUnstartCompetitions(){
        CompetitionEntityExample example = new CompetitionEntityExample();
        example.createCriteria().andStateEqualTo((short)0);
        return competitionEntityMapper.countByExample(example);
    }
    public long countACompetitions(){
        CompetitionEntityExample example = new CompetitionEntityExample();
        example.createCriteria().andStateEqualTo((short)1);
        return competitionEntityMapper.countByExample(example);
    }
    public long countBCompetitions(){
        CompetitionEntityExample example = new CompetitionEntityExample();
        example.createCriteria().andStateEqualTo((short)2);
        return competitionEntityMapper.countByExample(example);
    }
    public long countEndCompetitions(){
        CompetitionEntityExample example = new CompetitionEntityExample();
        example.createCriteria().andStateEqualTo((short)3);
        return competitionEntityMapper.countByExample(example);
    }

}
